<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 

// 선택옵션으로 인해 셀합치기가 가변적으로 변함
$colspan = 5;

//if ($is_category) $colspan++;
if ($is_checkbox) $colspan++;
if ($is_good) $colspan++;
if ($is_nogood) $colspan++;

// 제목이 두줄로 표시되는 경우 이 코드를 사용해 보세요.
// <nobr style='display:block; overflow:hidden; width:000px;'>제목</nobr>
?>

<link rel="stylesheet" type="text/css" href="/css/home.css">
<link rel="stylesheet" type="text/css" href="/css/reset.css">

<?
$SQL =  "SELECT SIDO,               ";
$SQL .= "       GUGUN,              ";
$SQL .= "       CASE                ";
$SQL .= "           WHEN SIDO='서울' ";
$SQL .= "           THEN 1          ";
$SQL .= "           WHEN SIDO='경기' ";
$SQL .= "           THEN 2          ";
$SQL .= "           WHEN SIDO='인천' ";
$SQL .= "           THEN 3          ";
$SQL .= "           WHEN SIDO='부산' ";
$SQL .= "           THEN 4          ";
$SQL .= "           WHEN SIDO='대구' ";
$SQL .= "           THEN 5          ";
$SQL .= "           WHEN SIDO='대전' ";
$SQL .= "           THEN 6          ";
$SQL .= "           WHEN SIDO='광주' ";
$SQL .= "           THEN 7          ";
$SQL .= "           WHEN SIDO='울산' ";
$SQL .= "           THEN 8          ";
$SQL .= "           WHEN SIDO='강원' ";
$SQL .= "           THEN 9          ";
$SQL .= "           WHEN SIDO='충북' ";
$SQL .= "           THEN 10         ";
$SQL .= "           WHEN SIDO='충남' ";
$SQL .= "           THEN 11         ";
$SQL .= "           WHEN SIDO='경북' ";
$SQL .= "           THEN 12         ";
$SQL .= "           WHEN SIDO='경남' ";
$SQL .= "           THEN 13         ";
$SQL .= "           WHEN SIDO='전북' ";
$SQL .= "           THEN 14         ";
$SQL .= "           WHEN SIDO='전남' ";
$SQL .= "           THEN 15         ";
$SQL .= "           WHEN SIDO='제주' ";
$SQL .= "           THEN 16         ";
$SQL .= "           ELSE 17         ";
$SQL .= "       END orderseq        ";
$SQL .= "  FROM g4_area             ";
$SQL .= " GROUP BY SIDO,            ";
$SQL .= "       GUGUN               ";
$SQL .= "ORDER BY orderseq,         ";
$SQL .= "       SIDO,               ";
$SQL .= "       GUGUN               ";

$area_arr = sql_query($SQL);

?>
<form id="" name="sidoSearchFrm" method="post">
</form>
<div id="wrap">
	<div id="contents" style="border-right:1px solid #c0c0c0;">
	<!-- contents -->
		<h1><a href="/"><img src="../img/comm/logo.gif" /></a></h1>
		<p style="text-align:center;margin-bottom:24px;"><img src="../img/home/txt090.gif" /></p>
		<p style="text-align:center;"><b><?=$param_data2?></b></p>
		<?
		$tempSido = '';
		$j=0;
		for ($i=0; $row=sql_fetch_array($area_arr); $i++) {
			if ($i==0){
				$tempSido = $row['SIDO'];
				$j=0;
		?>
		<h3><strong><a href="javascript:goMySearch('my_areaSearch', '<?=$param_data?>', '<?=$row['SIDO']?>');"><?=$row['SIDO']?></a></strong></h3>
		<div class="area_selt">
			<table>
				<tr>
		<?
			}else if ($tempSido!=$row['SIDO']){
				$tempSido = $row['SIDO'];
				$j=0;
		?>
				</tr>
			</table>
		</div>
		<h3><strong><a href="javascript:goMySearch('my_areaSearch', '<?=$param_data?>', '<?=$row['SIDO']?>');"><?=$row['SIDO']?></a></strong></h3>
		<div class="area_selt">
			<table>
				<tr>
			<?}else if ($j == 5){
				$j=0;
			?>
				</tr>
				<tr>
			<?}
				$j++;
			?>
					<td <? if ($j==5){echo "style=\"border:none;\"";}?>>
						<p><a href="javascript:goMySearch('my_areaSearch', '<?=$param_data?>', '<?=$row['SIDO']?> <?=$row['GUGUN']?>');"><?=$row['GUGUN']?></a></p>
					</td>
		<?}?>
				</tr>
			</table>
		</div>
	
	
	
	<!-- /contents -->
	</div>
	<div id="aside" style="border:none;">
	<!-- aside -->
		<div class="top_menu">
			<a href="/"><img src="../img/comm/smenu_home.gif" /></a>
			<img src="../img/comm/smenu_line.gif" />
			<a href="<?=$g4['path']?>/bbs/board_sellitem.php?bo_table=sellitem"><img src="../img/comm/smenu_buy01.gif" /></a>
			<img src="../img/comm/smenu_line.gif" />
			<a href="<?=$g4['path']?>/bbs/board_sellhome.php?bo_table=sellhome"><img src="../img/comm/smenu_home02.gif" /></a>
			<img src="../img/comm/smenu_line.gif" />
			<a href="#"><img src="../img/comm/smenu_job.gif" /></a>
		</div>
		<div class="user_info">
			<?=outlogin("basic2"); // 외부 로그인 ?>
		</div>
		<div class="icon_write">
			<a href="<?=$g4['path']?>/bbs/write_sellhome.php?bo_table=sellhome&chkItem=buy"><img src="../img/comm/bt_write01.gif" style="vertical-align:middle;" /></a>
		</div>
		<div style="text-align:center; margin-bottom:12px;">
			<a href="/bbs/board_sellhome.php?bo_table=sellhome"><img src="../img/home/tab01.gif" style="vertical-align:middle;" /></a>
			<a href="/bbs/board_buyhome.php?bo_table=buyhome"><img src="../img/home/tab02_on.gif" style="vertical-align:middle;" /></a>
		</div>
		<div class="select_way">
			<span><input type="radio" class="aty01" name="aty01" onclick="javascript:goMySearch('my_sellgubun','D1','<?=$param_data2?>');" <?if($param_data=="D1")echo "checked";?> value="D1" /> 월세</span>
			<span><input class="aty01" type="radio" name="aty01" onclick="javascript:goMySearch('my_sellgubun','D2','<?=$param_data2?>');" <?if($param_data=="D2")echo "checked";?> value="D2" /> 전세</span>
			<span><input class="aty01" type="radio" name="aty01" onclick="javascript:goMySearch('my_sellgubun','D3','<?=$param_data2?>');" <?if($param_data=="D3")echo "checked";?> value="D3" /> 매매</span>
		</div>
		<div class="days">
			<div style="width:101px; margin:0 auto;">
				<div style="height:55px; border-bottom:1px solid #dbdbdb; text-align:center;margin:0;margin-bottom:4px;"><img src="/img/comm/num_0<?=substr(date("d"),0,1)?>.jpg" alt="" /> <img src="/img/comm/num_0<?=substr(date("d"),1,1)?>.jpg" alt="" /> </div>
				<div style="overflow:hidden;">
					<div style="float:left;"><img src="/img/comm/mon_<?=date("m")?>.jpg" alt="" /></div>
					<div style="float:right;"><img src="/img/comm/year_<?=date("Y")?>.jpg" alt="" /></div>
				</div>
			</div>
		</div>
		<div id="dis_table">
	<? 
    for ($i=0; $i<count($list); $i++) { 
        $bg = $i%2 ? 0 : 1;
    ?>
		<!-- 매물01 -->
		<div class="home_info">
			<div class="mm_info03">
				<div style="text-align:right;margin-bottom:18px;">By <?=$list[$i][name]?>
					<div style="width:56px; height:19px; background:url('../img/product/days02_bg.gif') no-repeat; color:#fff; font-size:12px;text-align:center;padding-top:3px;">
					<?=$list[$i][diff]?>
					</div>
				</div>
				<div class="hope_info">
					<table width="100%">
						<tr>
							<td><img src="../img/home/stit_zone.gif" style="vertical-align:middle;" /></td>
							<td><img src="../img/home/stit_in.gif" style="vertical-align:middle;" /></td>
							<td><img src="../img/home/siti_pay.gif" style="vertical-align:middle;" /></td>
						</tr>
						<tr>
							<td><?=$list[$i][mb_addr1]?></td>
							<td><?=$list[$i][wr_4]?></td>
							<td><?if ($list[$i][wr_1]=='D1'){echo "<img src=\"../img/home/b_001.jpg\" style=\"vertical-align:middle;\" />";}else if ($list[$i][wr_1]=='D2'){echo "<img src=\"../img/home/b_002.jpg\" style=\"vertical-align:middle;\" />";} else if ($list[$i][wr_1]=='D3'){echo "<img src=\"../img/home/b_003.jpg\" style=\"vertical-align:middle;\" />";}?><?=han_price($list[$i][homePrice])?></td>
						</tr>
					</table>
				</div>

				<div style="color:#999; letter-spacing:-0.05em;margin-bottom:26px;">
					<?=$list[$i][wr_content]?>
				</div>
				<table width="100%" style="margin-bottom:15px;">
					<tr>
						<td valign="top" align="right">
							<a href="javascript:;" onclick="sSNS('twitter', '', '<?=str_replace(array("\r\n","\r","\n"), "<br/>", $list[$i][wr_content])?>');"><img src="../img/home/btn_tweeter.gif" style="vertical-align:middle;" /></a>
							<a href="javascript:;" onclick="sSNS('me2day', '', '<?=str_replace(array("\r\n","\r","\n"), "<br/>", $list[$i][wr_content])?>');"><img src="../img/home/btn_me2day.gif" style="vertical-align:middle;" /></a>
							<a href="javascript:;" onclick="sSNS('facebook', '', '<?=str_replace(array("\r\n","\r","\n"), "<br/>", $list[$i][wr_content])?>');"><img src="../img/home/btn_facebook.gif" style="vertical-align:middle;" /></a>
							<a href="javascript:;" onclick="sSNS('cyworld', '', '<?=str_replace(array("\r\n","\r","\n"), "<br/>", $list[$i][wr_content])?>');"><img src="../img/home/btn_cyworld.gif" style="vertical-align:middle;" /></a>
						</td>
						<td width="100" align="right">
				<? if ($member['mb_id']) { ?>
							<img src="../img/home/btn_pomm.gif" style="vertical-align:middle;cursor:pointer;" onclick="javascript:goScrap(<?=$list[$i][wr_id]?>);" />
				<? }	?>
							<p style="color:#999; padding-top:5px;">댓글(0)</p>
						</td>
					</tr>
				</table>
			</div>
		</div>
	<?}?>
		</div>
		
		<div>
			<a href="javascript:add_dis_table()">
				<img src="<?=$board_skin_path?>/img/btn_more.gif" align="absmiddle" border='0' alt="더보기">
			</a>
		</div>
	<!-- //aside -->
	</div>
</div>
<form name="ajaxFrm" method="post">
	<input type="hidden" name="page" value="<?=count($list)<12?0:$page?>">
</form>



<script type="text/javascript">
if ('<?=$sca?>') document.fcategory.sca.value = '<?=$sca?>';
if ('<?=$stx?>') {
    //document.fsearch.sfl.value = '<?=$sfl?>';

    /*if ('<?=$sop?>' == 'and') 
        document.fsearch.sop[0].checked = true;

    if ('<?=$sop?>' == 'or')
        document.fsearch.sop[1].checked = true;*/
} else {
    //document.fsearch.sop[0].checked = true;
}

function imgChange(imgNo, imgPath){
	$(".bigImg").eq(imgNo).attr("src",imgPath);
}

function showDetail(detailNo){

	if ($(".spanDiv").eq(detailNo).text()=="더보기"){
		$(".spanDiv").eq(detailNo).text("감추기");
		$(".divDetail").eq(detailNo).show("fast");
	}else{
		$(".spanDiv").eq(detailNo).text("더보기");
		$(".divDetail").eq(detailNo).hide("fast");
	}
}

function goScrap(wrId){
	$.ajax({
		  type: "POST",
		  url: "<?=$board_skin_path?>/scrap_ajax.php",
		  data: {
			  "mb_id": "<?=$member[mb_id]?>",
			  "bo_table": "<?=$bo_table?>",
			  "wr_id" : wrId
		  },
		  success: function(html){
			  if(html == "0"){
				alert("해당 상품을 관심매물에 추가하였습니다");
				$("#viewInter").text(eval($("#viewInter").text())+1);
			  }else{
			    alert("이미 관심매물에 등록된 상품입니다.");
			  }
		  }
	});
}

function add_dis_table(){
	$.ajax({
		  type: "POST",
		  url: "<?=$board_skin_path?>/list_view_ajax2.php",
		  data: {
			  "page": eval(document.ajaxFrm.page.value)+1,
			  "bo_gubun": "<?=$bo_gubun?>",
			  "sop": "<?=$sop?>",
			  "sca": "<?=$sca?>",
			  "sfl": "<?=$sfl?>",
			  "stx": encodeURIComponent('<?=$stx?>'),
			  "write_table": "<?=$g4['write_prefix'].$bo_table?>",
			  "bo_table": "<?=$bo_table?>",
			  "mb_id": "<?=$member['mb_id']?>",
			  "param_data": encodeURIComponent('<?=$param_data?>'),
			  "page_row": "3",
			  "is_admin":"<?=$is_admin?>",
			  "is_auth": "<?=$is_auth?>"
		  },
		  success: function(html){
			  if(html == "0"){
				  alert("더이상 데이터가 없습니다.");
				  return;
			  }else{
				  var objTbl = $("#dis_table")[0];
				  objTbl.insertAdjacentHTML("afterEnd", html);
				  document.ajaxFrm.page.value = eval(document.ajaxFrm.page.value)+1;
			  }
		  }
		});
}
</script>

<? if ($is_checkbox) { ?>
<script type="text/javascript">
function all_checked(sw) {
    var f = document.fboardlist;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_wr_id[]")
            f.elements[i].checked = sw;
    }
}

function check_confirm(str) {
    var f = document.fboardlist;
    var chk_count = 0;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_wr_id[]" && f.elements[i].checked)
            chk_count++;
    }

    if (!chk_count) {
        alert(str + "할 게시물을 하나 이상 선택하세요.");
        return false;
    }
    return true;
}

// 선택한 게시물 삭제
function select_delete() {
    var f = document.fboardlist;

    str = "삭제";
    if (!check_confirm(str))
        return;

    if (!confirm("선택한 게시물을 정말 "+str+" 하시겠습니까?\n\n한번 "+str+"한 자료는 복구할 수 없습니다"))
        return;

    f.action = "./delete_all.php";
    f.submit();
}

// 선택한 게시물 복사 및 이동
function select_copy(sw) {
    var f = document.fboardlist;

    if (sw == "copy")
        str = "복사";
    else
        str = "이동";
                       
    if (!check_confirm(str))
        return;

    var sub_win = window.open("", "move", "left=50, top=50, width=500, height=550, scrollbars=1");

    f.sw.value = sw;
    f.target = "move";
    f.action = "./move.php";
    f.submit();
}
</script>
<? } ?>
<!-- 게시판 목록 끝 -->
